from torchvision import datasets as dsets
from torchvision import transforms as transform
import torch


image_size=28


batch_size=64


def setting():
    train_data=dsets.MNIST(root='../data',train=True,transform=transform.ToTensor(),download=False)
    test_data=dsets.MNIST(root='../data',train=False,transform=transform.ToTensor())

    train_loader=torch.utils.data.DataLoader(dataset=train_data,batch_size=batch_size,shuffle=True)

    indices=range(len(test_data))
    indices_val=indices[:5000]
    indices_test=indices[5000:]

    sampler_val=torch.utils.data.sampler.SubsetRandomSampler(indices_val)
    sampler_test=torch.utils.data.sampler.SubsetRandomSampler(indices_test)

    val_loader=torch.utils.data.DataLoader(dataset=test_data,batch_size=batch_size,shuffle=False,sampler=sampler_val)
    test_loader=torch.utils.data.DataLoader(dataset=test_data,batch_size=batch_size,shuffle=False,sampler=sampler_test)

    return train_loader,val_loader,test_loader


